import 'package:find_friend/common/alert_tool.dart';
import 'package:find_friend/common/event_bus.dart';
import 'package:find_friend/const/const.dart';
import 'package:find_friend/pages/mine/mine.dart';
import 'package:find_friend/pages/mine/mine_dressup/mine_clothes.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class MineDressupWidget extends StatefulWidget {
  @override
  _MineDressupWidgetState createState() => _MineDressupWidgetState();
}

class _MineDressupWidgetState extends State<MineDressupWidget> {

  @override
  void initState() {
    super.initState();

    EventMineBus.instance.addListener(EventMineKeys.AlertDressupWidget, (arg) {  
      _alert();
    });
  }

  void _alert() {
    push(context, MineClothesPage());
  }

  @override
  Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size;
    bool hidden = ShareDataWidget.of(context).isbottom;
    return Positioned.fill(
      child: Stack(
        alignment: Alignment.center,
        children: [
          Image.asset("assets/jia.png", height: size.height, width: size.width, fit: BoxFit.cover),
          SafeArea(
            bottom: false,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Opacity(
                  opacity: hidden ? 1 : 0,
                  child: Padding(
                    padding: const EdgeInsets.only(top: 20),
                    child: Text("我的装扮", style: instanceTextStyle(17, APP_font_black),)
                  ),
                ),
                Center(
                  child: Padding(
                    padding: const EdgeInsets.only(bottom: 100),
                    child: Image.asset("assets/mm.png", fit: BoxFit.scaleDown,),
                  ),
                ),
              ],
            ),
          ),

          Positioned(
            bottom: 100,
            right: 17,
            child: InkWell(
              onTap: _alert,
              child: Stack(
                alignment: Alignment.center,
                children: [
                  Image.asset("assets/quhuanzhuang.png"),
                  Positioned(
                    bottom: 3,
                    child: Text("去换装", style: instanceTextStyle(11, Colors.white),),
                  )
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }
}